package cn.ee.dfs.wx.service.impl;

import cn.ee.dfs.common.entity.QueryRequest;
import cn.ee.dfs.wx.model.WxUser;
import cn.ee.dfs.wx.mapper.WxuserMapper;
import cn.ee.dfs.wx.service.IWxuserService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.beans.factory.annotation.Autowired;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

/**
 * 微信用户表 Service实现
 *
 * @author TWJ
 * @date 2023-07-29 12:23:31
 */
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class WxuserServiceImpl extends ServiceImpl<WxuserMapper, WxUser> implements IWxuserService {

    @Autowired
    private WxuserMapper wxuserMapper;

    @Override
    public IPage<WxUser> findWxusers(QueryRequest request, WxUser wxuser) {
        LambdaQueryWrapper<WxUser> queryWrapper = new LambdaQueryWrapper<>();
        // TODO 设置查询条件
        Page<WxUser> page = new Page<>(request.getPageNum(), request.getPageSize());
        return this.page(page, queryWrapper);
    }



    @Override
    public List<WxUser> findWxusers(WxUser wxuser) {
	    LambdaQueryWrapper<WxUser> queryWrapper = new LambdaQueryWrapper<>();
		// TODO 设置查询条件
		return this.baseMapper.selectList(queryWrapper);
    }

    @Override
    @Transactional
    public void createWxuser(WxUser wxuser) {
        this.save(wxuser);
    }

    @Override
    @Transactional
    public void updateWxuser(WxUser wxuser) {
        this.saveOrUpdate(wxuser);
    }

    @Override
    @Transactional
    public void deleteWxuser(WxUser wxuser) {
        LambdaQueryWrapper<WxUser> wapper = new LambdaQueryWrapper<>();
	    // TODO 设置删除条件
	    this.remove(wapper);
	}
}
